package com.activenetwork.util.datepicker;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;

import com.activenetwork.smlite.page.generic.PageObject;
import com.activenetwork.util.PageLoader;
import com.activenetwork.util.WaitUtil;

public class CalendarMonthDiv implements PageObject {
	private WaitUtil waitUtil = new WaitUtil(500);
	
	@FindBy(how = How.CSS, using = ".datepicker.dropdown-menu[style*='display: block;'] div.datepicker-months")
	private WebElement div;
	
	public CalendarYearDiv switchYear(){
		div.findElement(By.xpath(".//th[@class='switch']")).click();
		waitUtil.waiting();
		return PageLoader.load(CalendarYearDiv.class);
	}
	
	public CalendarDateDiv pick(int month){
		List<WebElement> months = div.findElements(By.xpath(".//span[contains(@class, 'month')]"));
		months.get(month).click();
		waitUtil.waiting();
		return PageLoader.load(CalendarDateDiv.class);
	}
}
